package com.tudouji.project.bill.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.bill.domain.Whinforecord;
import com.tudouji.project.bill.service.IWhinforecordService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 每日库存Controller
 * 
 * @author tudouji
 * @date 2023-04-27
 */
@RestController
@RequestMapping("/whinforecord/whinforecord")
public class WhinforecordController extends BaseController
{
    @Autowired
    private IWhinforecordService whinforecordService;

    /**
     * 查询每日库存列表
     */
    @PreAuthorize("@ss.hasPermi('whinforecord:whinforecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(Whinforecord whinforecord)
    {
        startPage();
        List<Whinforecord> list = whinforecordService.selectWhinforecordList(whinforecord);
        return getDataTable(list);
    }

    /**
     * 导出每日库存列表
     */
    @PreAuthorize("@ss.hasPermi('whinforecord:whinforecord:export')")
    @Log(title = "每日库存", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Whinforecord whinforecord)
    {
        List<Whinforecord> list = whinforecordService.selectWhinforecordList(whinforecord);
        ExcelUtil<Whinforecord> util = new ExcelUtil<Whinforecord>(Whinforecord.class);
        return util.exportExcel(list, "whinforecord");
    }

    /**
     * 获取每日库存详细信息
     */
    @PreAuthorize("@ss.hasPermi('whinforecord:whinforecord:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(whinforecordService.selectWhinforecordById(guid));
    }

    /**
     * 新增每日库存
     */
    @PreAuthorize("@ss.hasPermi('whinforecord:whinforecord:add')")
    @Log(title = "每日库存", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Whinforecord whinforecord)
    {
        return toAjax(whinforecordService.insertWhinforecord(whinforecord));
    }

    /**
     * 修改每日库存
     */
    @PreAuthorize("@ss.hasPermi('whinforecord:whinforecord:edit')")
    @Log(title = "每日库存", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Whinforecord whinforecord)
    {
        return toAjax(whinforecordService.updateWhinforecord(whinforecord));
    }

    /**
     * 删除每日库存
     */
    @PreAuthorize("@ss.hasPermi('whinforecord:whinforecord:remove')")
    @Log(title = "每日库存", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(whinforecordService.deleteWhinforecordByIds(guids));
    }
}
